package com.mars.pay.common;

import lombok.Getter;

/**
 * 支付状态枚举
 *
 * @author Mars
 */
@Getter
public enum PaymentStatusEnum {

    /**
     * 待支付
     */
    WAIT_PAY(0, "待支付"),

    /**
     * 支付中
     */
    PAYING(1, "支付中"),

    /**
     * 支付成功
     */
    SUCCESS(2, "支付成功"),

    /**
     * 支付失败
     */
    FAILED(3, "支付失败"),

    /**
     * 已退款
     */
    REFUND(4, "已退款"),

    /**
     * 已关闭
     */
    CLOSED(5, "已关闭");

    private final Integer code;
    private final String desc;

    PaymentStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据 code 获取枚举
     */
    public static PaymentStatusEnum getByCode(Integer code) {
        for (PaymentStatusEnum status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }
}

